import 'package:enterprise_v6_app/app/components/custom_modele/custom_card.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_dropdown_selection.dart';
import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standard_scence_health_protect_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standard_scence_health_three_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standardization_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/standardization/common.dart';
import 'package:enterprise_v6_app/app/modules/application/standardization/pages/scence/health/ctrl.dart';
import 'package:enterprise_v6_app/app/modules/application/standardization/pages/scence/health/model.dart';

/// 职业健康
class StandardizationScenceHealthView extends StatelessWidget {
  StandardizationScenceHealthView({super.key});

  final ctrl = Get.put(StandardizationScenceHealthController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
      init: ctrl,
      builder: (_) {
        return Column(
          children: [
            CustomDropdownSelection(
              text: ctrl.type.name,
              onCallBack: ctrl.showSelect,
              height: 37.w,
            ),
            AppGaps.vGap10,
            Expanded(child: _buildBody()),
          ],
        );
      },
    );
  }

  Widget _buildBody() {
    if (ctrl.type == StandardizationHealthMenuType.threeSimultaneity) {
      return CustomEasyRefreshList<StandardScenceHealthThreeEntity>(
        key: ValueKey(ctrl.type),
        isShowSearch: true,
        dataLoad: ctrl.getThree,
        itemBuilder: (entity, _) {
          return CustomCard(
            title: entity.name,
            // onTap: () => FileUtils.openFile(entity.),
            // titleRight: SvgPicture.asset(AppImages.icon_job_right),
            divider: CustomCard.builtinDividerWithPadding,
            content: Column(
              children: [
                StandardizationCommon.buildItem('时间', entity.createDate),
              ],
            ),
          );
        },
      );
    } else if (ctrl.type == StandardizationHealthMenuType.equipment) {
      return CustomEasyRefreshList<StandardScenceHealthProtectEntity>(
        key: ValueKey(ctrl.type),
        isShowSearch: true,
        dataLoad: ctrl.getProtect,
        itemBuilder: (entity, _) {
          return CustomCard(
            title: entity.name,
            divider: CustomCard.builtinDividerWithPadding,
            content: Column(
              children: [
                StandardizationCommon.buildItem('数量', entity.number?.toString()),
                AppGaps.vGap10,
                StandardizationCommon.buildItem('存储点', entity.savePoint),
                AppGaps.vGap10,
                StandardizationCommon.buildItem('责任人', entity.personResponsible),
              ],
            ),
          );
        },
      );
    }
    return CustomEasyRefreshList<StandardizationEntity>(
      key: ValueKey(ctrl.type),
      isShowSearch: true,
      dataLoad: ctrl.getPages,
      itemBuilder: StandardizationCommon.card,
    );
  }
}
